package scau.erps.view.decision.sand;

import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

import scau.erps.app.Erps;
import scau.erps.service.ResearchService;
import scau.erps.service.impl.ResearchServiceImpl;

public class IsoPanel extends JPanel{
	private static final long serialVersionUID = 1L;
	private JCheckBox[] jck = new JCheckBox[2];
	public IsoPanel(String name){
		JPanel isoPanel = new JPanel(new GridLayout(3,1,2,2));
		isoPanel.setPreferredSize(new Dimension(80,75));
		JLabel label = new JLabel(name);
		jck[0] = new JCheckBox("1Y");
		jck[1] = new JCheckBox("2Y");
		jck[0].setEnabled(false);
		jck[1].setEnabled(false);
		isoPanel.add(label);
		isoPanel.add(jck[0]);
		if("ISO14000".equals(name)){
			isoPanel.add(jck[1]);
		}
		this.setCheckBoxValue(name);
		this.add(isoPanel);		
	}
	public void setCheckBoxValue(String name){
		int team_Id = Erps.getCurrentTeam().getId();
		ResearchService researchService = Erps.getIocInstance().get(ResearchServiceImpl.class);
		int j = researchService.findResearchs(team_Id,name);
		for (int i = 0; i < j; i++) {
			jck[i].setSelected(true);
		}		
	}
}
